package controller;

import protocol.Request;
import service.Result;

import java.util.Map;

/**
 * @author yuzk
 * @date 2018/1/17
 */
public class Dispatcher {

    public static Result dispatch(String path, Map<String, Object> params){
        if(path.contains(Path.Calculate.BASE)){
            return ControllerFactory.getCalculate().handleRequest(path, params);
        }
        return Result.error("dispatch error");
    }

    public static Result dispatch(Request request){
        return dispatch(request.getPath(), request.getParams());
    }
}
